package br.com.fafica.sisape.repositorioarray;

import java.util.ArrayList;

import br.com.fafica.sisape.model.Hospital;;

public class RepositorioHospital {
	
	static ArrayList <Hospital> hospitais = new ArrayList<Hospital>();
	static Integer cod = 0;
	
	public void createHospital(Hospital hospital){
		cod ++;
		hospital.setCod(cod);
		hospitais.add(hospital);
	}
	public ArrayList readHospital(){
		
		return hospitais;
	}
	public void updateHospital(Hospital hospital){
		
		for(int i = 0; i < hospitais.size(); i++){
			if(hospitais.get(i).getCod() == hospital.getCod()){
				hospitais.set(i, hospital);
			}
		}
	}
	public void deleteHospital(Hospital hospital){
		
		for(int i = 0; i < hospitais.size(); i++){
			if(hospitais.get(i).getCod() == hospital.getCod()){
				hospitais.remove(i);
			}
		}
		
	}

}